﻿
@{
    ViewBag.Title = "RoleList";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    var data = ViewBag.RoleList as List<LuDragon.Data.Entities.Sys_Role>;

}


<span class="layui-breadcrumb">
    <a>系统设置</a>
    <a>角色管理</a>
    <a><cite>列表</cite></a>
</span>
<hr />
<button class="layui-btn" onclick="location.href='RoleEdit'"><i class="layui-icon">&#xe654;</i>新增</button>
<div class="table-list layui-form">
    <table class="layui-table layui-list-table">
        <thead>
            <tr>
                <th>角色名称</th>
                <th>是否系统角色</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @for (int i = 0; i < data.Count; i++)
            {
                <tr>
                    <td><span class="layui-table-bd">@data[i].RoleName</span></td>
                    <td>
                        <span class="layui-table-bd">@(data[i].IsSystem ? "是" : "否")</span>
                    </td>
                    <td class="layui-table-btn">
                        <button title="编辑" class="layui-btn layui-btn-normal layui-btn-small" onclick="location.href='RoleEdit?id=@data[i].RoleId'">
                            <i class="layui-icon">&#xe642;</i>
                        </button>
                        <button title="菜单权限" class="layui-btn layui-btn-warm layui-btn-small" onclick="location.href='RoleControl?id=@data[i].RoleId'">
                            <i class="layui-icon">&#xe620;</i>
                        </button>
                        @if (!data[i].IsSystem)//系统菜单不能删除
                        {
                            <button title="删除" class="layui-btn layui-btn-danger layui-btn-small" onclick="Del(@data[i].RoleId);">
                                <i class="layui-icon">&#xe640;</i>
                            </button>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
<script>
    function Del(id) {
        dialog.dialog("删除操作不可恢复，您确认要删除吗？", function () {
            $.post("DelRole", { "id": id }, function (result) {
                var data = JSON.parse(result);
                if (data.Code == 200) {
                    location.reload();
                } else {
                    dialog.prompt("操作失败，请稍后重试。");
                }
            })
        });
    }
</script>

